import React, { Component } from 'react'
import ReactDOM from 'react-dom';
import { Modal, Form, message } from 'antd';
import { fetchData } from '../../../components/AjaxConsumer'
import CheckFrom from './CheckFrom'

const confirm = Modal.confirm;

export default class CheckPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            formTitle: '',
            visible: false,
            rowData: null,
            suburl: '/product/hand/audit'
        };
    }

    //显示弹框
    showModal = () => {
        this.setState({
            visible: true,
        });
    }

    // 隐藏弹出框
    hideModal = () => {
        this.setState({
            visible: false,
        });
    }

    checkHandle = (rowObj) => {
        this.setState({
            visible: true,
            formTitle: '审核',
            rowData: rowObj[0].data
        });
    }

    handleOk = () => {
        this.hideModal();
        this.refreshHandle();
    }

    handleCancel = () => {
        //表单重置
        this.refs.checkFrom.resetFields();
        this.hideModal();
    }

    //刷新List列表
    refreshHandle = () => {
        console.log("刷新List列表")
        this.props.refreshHandle();
    }

    render() {
        return (
            <Modal
                style={{ top: '20px' }}
                visible={this.state.visible}
                title={this.state.formTitle ? this.state.formTitle : '填写表单'}
                onOk={this.handleOk}
                onCancel={this.handleCancel}
                width={this.formAlerSize == 'large' ? '850px' : '400px'}
                footer=''
            >

                <CheckFrom
                    ref="checkFrom"
                    onCancel={this.handleCancel}
                    factoryCode="all"
                    rowData={this.state.rowData}
                    refreshHandle={this.refreshHandle}
                    suburl ={this.state.suburl}
                />

            </Modal>
        )
    }
}